home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Just Call Me Internet
/
Just Call Me Internet.iso
/
prog
/
atari
/
m2
/
cat3src
/
cat
/
arcstart.i
< prev
next >
Wrap
Text File
|
1997-10-26
|
4KB
|
149 lines
IMPLEMENTATION MODULE ARCStarter;
FROM SYSTEM IMPORT ADDRESS, ADR;
FROM CatFiles IMPORT GetPath, SetPath;
FROM MTPaths IMPORT ImportPath, ExportPath, ARCPath, ARCName,
MessagePath, enarcStr, dearcStr;
FROM ARCAss IMPORT SetTrap, RestoreTrap, TrapProc, SetCharAddress, SetNewProc,
SetOutputProc, ClearOutputProc;
FROM Void IMPORT v;
FROM UserInformation IMPORT UserBLK;
IMPORT MagicDOS;
IMPORT MagicStrings;
IMPORT mtDir;
IMPORT CatGlobal;
IMPORT CatLog;
IMPORT MintUtil;
IMPORT ExecV;
(*$R-,S-*)
(* entarct Datei <FileName> im PortOrdner, returns ARC exit code *)
VAR outputDone: BOOLEAN;
PROCEDURE ClearScreen();
BEGIN
MagicDOS.Cconout(33C); MagicDOS.Cconout('E');
END ClearScreen;
PROCEDURE outProc (ch: CHAR);
BEGIN
outputDone := TRUE;
CatLog.Write (ch);
END outProc;
PROCEDURE ExecProgram (VAR name, cmd: ARRAY OF CHAR; toLog: BOOLEAN;
noRedirect: BOOLEAN; redraw: BOOLEAN; VAR res: INTEGER);
(* Wenn noRedirect angegeben ist, dann wird die Ausgabe des Programmes
* nie umgelenkt.
*)
VAR env: ARRAY [0..1] OF CHAR;
pid,
pipe : INTEGER;
size : LONGINT;
arcName : ARRAY [0..255] OF CHAR;
currentPath,
path : ARRAY [0..255] OF CHAR;
BEGIN
outputDone := FALSE;
mtDir.SplitPath (name, path, arcName, currentPath);
GetPath (currentPath);
IF SetPath (path) THEN END;
env := '';
IF MintUtil.IsMiNT() & ~noRedirect
THEN
(* Packer starten und Ausgabe in Pipe umlenken und Pipe leerlesen *)
pid := MintUtil.ExecPipe (name,cmd,env,pipe);
IF pid > 0
THEN
REPEAT
size := MintUtil.ReadPipe (pid, pipe, arcName, res);
IF (size > 0) & toLog
THEN
(* berlauf vermeiden *)
IF SHORT(size) < SIZE(arcName)
THEN
arcName[SHORT(size)] := 0c;
END;
outputDone := TRUE;
CatLog.WriteString (arcName);
END;
UNTIL size < 0;
ELSE
IF pid = 0 THEN
res := -1;
ELSE
res := pid;
END;
RETURN
END;
ELSE
IF UserBLK.RedirectArcer & ~noRedirect
THEN
SetTrap();
IF toLog & CatGlobal.magIx & (CatGlobal.magIxVer >= $200)
THEN
SetOutputProc (ADDRESS(outProc));
END;
ELSE
ClearScreen();
END;
IF ORD(cmd[0]) > 126 (* Lnge der Kommandozeile *)
THEN
res := ExecV.Pexec(MagicDOS.LoadnGo, name, cmd, env);
ELSE
res := MagicDOS.Pexec(MagicDOS.LoadnGo, name, cmd, env);
END;
IF UserBLK.RedirectArcer & ~noRedirect THEN
RestoreTrap();
IF toLog
THEN
ClearOutputProc ();
END;
ELSE
IF redraw THEN CatGlobal.FullScreenRedraw(); END;
END;
END;
IF toLog & outputDone THEN CatLog.WriteLn; END;
IF SetPath (currentPath) THEN END;
END ExecProgram;
PROCEDURE DeArc(toLog: BOOLEAN):INTEGER;
VAR cmd,env : ARRAY[0..127] OF CHAR;
res : INTEGER;
arcName : ARRAY [0..255] OF CHAR;
pid,
pipe : INTEGER;
size : LONGINT;
BEGIN
cmd := ' ';
MagicStrings.Append(dearcStr, cmd);
cmd[0] := CHR(MagicStrings.Length(cmd));
env := '';
MagicStrings.Assign (ARCPath, arcName);
MagicStrings.Append (ARCName, arcName);
ExecProgram (arcName, cmd, toLog, FALSE, TRUE, res);
RETURN res
END DeArc;
PROCEDURE Archive():INTEGER;
VAR cmd,env : ARRAY[0..127] OF CHAR;
res : INTEGER;
arcName : ARRAY [0..255] OF CHAR;
pid,
pipe : INTEGER;
size : LONGINT;
BEGIN
cmd := ' ';
MagicStrings.Append(enarcStr, cmd);
cmd[0] := CHR(MagicStrings.Length(cmd));
env := '';
MagicStrings.Assign (ARCPath, arcName);
MagicStrings.Append (ARCName, arcName);
ExecProgram (arcName, cmd, FALSE, FALSE, TRUE, res);
RETURN res
END Archive;
END ARCStarter.